// @ts-nocheck
export default {
  async viewClickType({ type = '' } = {}) {
    const self = this;
    if (type == '放大') {
      await self.vickMapPostMessage({
        key: 'cameraZoomIn'
      });
    } else if (type == '缩小') {
      await self.vickMapPostMessage({
        key: 'cameraZoomOut'
      });
    } else if (type == '获取当前位置坐标') {
      let positionObject = await self.vickMapPostMessage({
        key: 'cameraPositionGet',
        value: {
          coordinatesSystem: 'cgcs2000'
        }
      });
      self.setState({
        messageObject: {
          positionObject: positionObject
        }
      });
    } else if (type == 'cgcs2000坐标转换为bd09、gcj02坐标') {
      let positionObject = await self.vickMapPostMessage({
        key: 'cameraPositionGet',
        value: {
          coordinatesSystem: 'cgcs2000'
        }
      });
      let coordinates = await self.vickMapPostMessage({
        key: 'coordinatesTransform',
        value: {
          coordinates: [
            [positionObject.longitude, positionObject.latitude],
            [positionObject.west, positionObject.south],
            [positionObject.east, positionObject.north]
          ],
          from: 'cgcs2000',
          to: 'bd09'
        }
      });
      positionObject.bd09Longitude = coordinates[0][0];
      positionObject.bd09Latitude = coordinates[0][1];
      positionObject.bd09West = coordinates[1][0];
      positionObject.bd09South = coordinates[1][1];
      positionObject.bd09East = coordinates[2][0];
      positionObject.bd09North = coordinates[2][1];
      coordinates = await self.vickMapPostMessage({
        key: 'coordinatesTransform',
        value: {
          coordinates: [
            [positionObject.longitude, positionObject.latitude],
            [positionObject.west, positionObject.south],
            [positionObject.east, positionObject.north]
          ],
          from: 'cgcs2000',
          to: 'gcj02'
        }
      });
      positionObject.gcj02Longitude = coordinates[0][0];
      positionObject.gcj02Latitude = coordinates[0][1];
      positionObject.gcj02West = coordinates[1][0];
      positionObject.gcj02South = coordinates[1][1];
      positionObject.gcj02East = coordinates[2][0];
      positionObject.gcj02North = coordinates[2][1];
      self.setState({
        messageObject: {
          positionObject: positionObject
        }
      });
    }
  }
};
